#include "gpio.h"

/************************************************************
 * @brief: GIPO Output reverse
 * @return <None>
 ************************************************************/
void GPIO_TogglePin(uint32_t pin)
{
	uint32_t pin_value,last_pin_value;
	pin_value = GPIO->PDO;
	last_pin_value = (pin_value >> pin) & 0x01;
	
	pin_value &= (~(0x01 << pin) & 0x7FF); // clean bit
	pin_value |= (~last_pin_value << pin); // reverse
	GPIO->PDO = pin_value;
}

/************************************************************
 * @brief: GIPO clean bit
 * @return <None>
 ************************************************************/
void GPIO_CleanPin(uint32_t pin)
{
	uint32_t pin_value = GPIO->PDO;
	pin_value &= (~(0x01 << pin) & 0x7FF); // clean bit
	GPIO->PDO = pin_value;
}

/************************************************************
 * @brief: GIPO set bit
 * @return <None>
 ************************************************************/
void GPIO_SetPin(uint32_t pin)
{
	uint32_t pin_value = GPIO->PDO;
	pin_value |= (0x01 << pin);
}
